Skip to content

Comments

fix: add network error retry for transfer polling#763

Merged
ovitrif merged 6 commits intomasterfrom
fix/transfer-network-error-handling
Feb 10, 2026
Merged

fix: add network error retry for transfer polling#763
ovitrif merged 6 commits intomasterfrom
fix/transfer-network-error-handling

Conversation

@jvsena42
Copy link
Member

@jvsena42 jvsena42 commented Feb 3, 2026

Fixes #608

This PR adds network error resilience to the transfer-to-spending polling mechanism by distinguishing between transient network failures and permanent order errors.

Description

  • Uses .fold() instead of .getOrNull() to properly handle Result failures
  • Implements a retry mechanism that tolerates up to 5 consecutive network errors before giving up
  • Resets the error counter on successful fetches, allowing recovery from intermittent issues
  • Preserves immediate exit behavior for permanent failures (order not found, order expired)

Preview

Screen_recording_20260206_132910.mp4

QA Notes

To facilitate the simulation, you can put a breakpoint in the line and then disable internet

 val paidOrder = pollUntil(orderId) { order ->

1. Normal transfer flow (regression)

  1. Start a transfer to spending
  2. Verify the setup steps progress (0 → 1 → 2 → 3)
  3. Confirm the channel opens successfully

2. Network error recovery

  1. Start a transfer to spending
  2. Enable airplane mode briefly during polling
  3. Disable airplane mode before 12.5 seconds (5 retries × 2.5s)
  4. Verify polling resumes and completes successfully

3. Persistent network failure

  1. Start a transfer to spending
  2. Enable airplane mode and keep it enabled
  3. After ~12.5 seconds, verify the transfer fails gracefully with appropriate logging

@jvsena42 jvsena42 self-assigned this Feb 3, 2026
@jvsena42 jvsena42 marked this pull request as ready for review February 6, 2026 16:31
@jvsena42
Copy link
Member Author

jvsena42 commented Feb 6, 2026

from the Logs

2026-02-06 13:29:34.832 14603-14603 APP                     to.bitkit.dev                        W  2026-02-06 16:29:34.831 WARN    [TransferViewModel.kt:287]           Failed to fetch order '579f1d43-647c-4844-9d39-64b0d9336e52' (attempt 3/5) [AppError='errorDetails=Failed to fetch orders: Blocktank error: Failed to fetch orders ["579f1d43-647c-4844-9d39-64b0d9336e52"]: HTTP client error: error sending request for url (https://api.stag0.blocktank.to/blocktank/api/v2/channels?ids%5B%5D=579f1d43-647c-4844-9d39-64b0d9336e52) String("HTTP client error: error sending request for url (https://api.stag0.blocktank.to/blocktank/api/v2/channels?ids%5B%5D=579f1d43-647c-4844-9d39-64b0d9336e52)")'] - TransferViewModel
                                                                                                    to.bitkit.utils.AppError: errorDetails=Failed to fetch orders: Blocktank error: Failed to fetch orders ["579f1d43-647c-4844-9d39-64b0d9336e52"]: HTTP client error: error sending request for url (https://api.stag0.blocktank.to/blocktank/api/v2/channels?ids%5B%5D=579f1d43-647c-4844-9d39-64b0d9336e52) String("HTTP client error: error sending request for url (https://api.stag0.blocktank.to/blocktank/api/v2/channels?ids%5B%5D=579f1d43-647c-4844-9d39-64b0d9336e52)")
                                                                                                    	at to.bitkit.async.ServiceQueue$background$2.invokeSuspend(ServiceQueue.kt:42)

@jvsena42 jvsena42 marked this pull request as draft February 6, 2026 17:14
@jvsena42

This comment was marked as resolved.

@jvsena42 jvsena42 marked this pull request as ready for review February 10, 2026 12:18
@claude
Copy link

claude bot commented Feb 10, 2026

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

2 similar comments
@claude
Copy link

claude bot commented Feb 10, 2026

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@claude
Copy link

claude bot commented Feb 10, 2026

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@jvsena42 jvsena42 requested a review from ovitrif February 10, 2026 15:58
Copy link
Collaborator

@ovitrif ovitrif left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utAck

@ovitrif ovitrif enabled auto-merge February 10, 2026 16:11
@ovitrif ovitrif merged commit 1767828 into master Feb 10, 2026
19 of 25 checks passed
@ovitrif ovitrif deleted the fix/transfer-network-error-handling branch February 10, 2026 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Spending balance remains 0 after opening the channel from the app, despite transfer to spending confirmed (Android)

2 participants